<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" autofocus>
    <script>
        var input = document.querySelector("input");
        input.onchange = function (){
            alert(input.value);
        }
        input.oninput = function (){
            console.log(input.value);
        }
        input.onfocus = function (){
            console.log("在聚焦");//如果在input框内给一个自动聚焦属性，就会直接触发该事件
        }
        input.onblur = function (){
            console.log("失去焦点");
        }
    </script>
</body>
</html>